#include <bits/stdc++.h>
#include "../../tools/tools.h"
using namespace std;

constexpr int INF = 0x7fffffff; // 无穷大
typedef long long ll;

class Solution {
public:
    int minOperations(vector<int>& nums) {
        int n = nums.size();
        int ans = 0;
        for(int i = 0; i < n - 2; i++) {
            if(nums[i] == 0) {
                ans++;
                nums[i] = 1;
                nums[i + 1] = 1 - nums[i + 1];
                nums[i + 2] = 1 - nums[i + 2];
            }
        }
        return nums[n - 1] + nums[n - 2] == 2 ? ans : -1;

    }
};

int main(int argc, const char** argv) {
    // Solution s;
    vector<int> data;
    data = {4, 2, 6, 3, 9};
    // debug();
    return 0;
}
